<?php
session_start();
if (isset($_SESSION['openid']) && isset($_POST['key'])){
    include '../c/config.php';
    $openid=$_SESSION['openid'];
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    
    $queryG=$mysqli->query("select tid from ".$tableVer."_group where openid='".$openid."'  limit 0, 1");
    if($queryG->num_rows>0){
        $getG=$queryG->fetch_assoc();
        $tid=$getG['tid'];
    }
    $mysqli->query("delete from ".$tableVer."_group where openid='".$openid."' ");
    $queryC=$mysqli->query("select id from ".$tableVer."_group where tid='".$tid."'  limit 0, 1");
    if($queryC->num_rows>0){
        
    }else{
        $mysqli->query("update ".$tableVer."_team set iswork=2 where id='".$tid."' ");
    }
    
    $queryC=$mysqli->query("select count(id) as count from ".$tableVer."_group where tid='".$tid."'  ");
    $getCount=$queryC->fetch_assoc();
    $mysqli->query("update ".$tableVer."_team set renshu=".$getCount['count']." where id='".$tid."' ");
    
    echo json_encode(array('s'=>'y'));
}
?>